#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int arr[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int year = 0, month = 0, day = 0,sum=0,i=0;
	scanf("%d %d %d", &year, &month, &day);
	if (year % 4 == 0 && year % 100 == 0 || year % 400 == 0)
	{
		arr[2] = 29;
	}
	for (i = 0; i <month; i++)
	{
		sum += arr[i];
	}
	sum += day;
	printf("%d\n", sum);
	return 0;
}